package walkthetalktech.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ResourceBundle;

public class PropertyFileReader {
	
	static Logger logger = LoggerFactory.getLogger(PropertyFileReader.class);
	
	public static String getItem(String key) {
		return getItem(key, "");
	}
	
	public static String getItem(String key, String defaultValue) {
		ResourceBundle rb = ResourceBundle.getBundle("stark");
		String value = "";
        
        try {
        	value = rb.getString(key);
        } catch (Exception e) {
        	logger.error("error occured in read property file.");
        }
        
        if (StringUtils.isEmptyString(value)) {
        	value = defaultValue;
        }
        
        return value.trim();
	}
	
	public static int getIntItem(String key) {
		return getIntItem(key, "0");
	}
	
	public static long getLongItem(String key) {
		return getLongItem(key, "0");
	}
	
	public static boolean getBooleanItem(String key) {
		return getBooleanItem(key, "true");
	}
	
	public static long getLongItem(String key, String defaultValue) {
		return Long.parseLong(getItem(key, defaultValue));
	}
	
	public static int getIntItem(String key, String defaultValue) {
		return Integer.parseInt(getItem(key, defaultValue));
	}
	
	public static boolean getBooleanItem(String key, String defaultValue) {
		return Boolean.parseBoolean(getItem(key, defaultValue));
	}
}
